
**** Figure 1 on growth rates 

use "$datadir\ewallet\aggregate_ewallets_weekly.dta", clear 

	sort time 
	gen trans_growth = (transaction-transaction[_n-1])/transaction[_n-1]
	replace trans_growth = 0 if time == 1
	gen amount_growth = (amount-amount[_n-1])/amount[_n-1]
	replace amount_growth = 0 if time == 1
	replace time = time - 28
		
	foreach var of varlist amount transaction{
		g `var'_normalized = `var'/100 if time == -1
		egen x = max(`var'_normalized)
		replace `var'_normalized = x
		drop x
		replace `var'_normalized = `var'/`var'_normalized
	}
	
	label var trans_growth "Growth Rate (Transactions)"
	label var amount_growth "Growth Rate (Amount)"
	label var transaction_normalized "Transactions (Normalized)"
	label var amount_normalized "Amount (Normalized)"
	label var time "Time(Week)"
	
	graph set window fontface "Garamond"
	local upper = 2
	local lower = -0.5
	g upper = `upper'
	local barcall upper time if inrange(time, 0, 11.98), bcolor(gray%20) lcolor(gray%5) base(`lower') lwidth(0)
	local graphs ""
	twoway (bar `barcall') (scatter trans_growth time, msymbol(circle) msize(med) mcolor(black) connect(l) lcolor(gray)), ///
	legend(off) graphregion(color(white)) ylab(-0.5(0.5)2,nogrid) xlabel(-30 (10) 30)  xtitle("Weeks") ytitle("Growth Rate (Transactions)")  ///
	xline(-0.5 12, lcolor(black) lwidth(thin) lpattern(dash)) plotregion(lcolor(black) margin(b=0.25 t=0.25)) name(g1,replace) nodraw
	local graphs "`graphs' g1"
	twoway (bar `barcall') (scatter amount_growth time, msymbol(circle) msize(med) mcolor(black) connect(l) lcolor(gray)), ///
	legend(off) graphregion(color(white)) ylab(-0.5(0.5)2,nogrid) xlabel(-30 (10) 30)  xtitle("Weeks") ytitle("Growth Rate (Amount)")  ///
	xline(-0.5 12, lcolor(black) lwidth(thin) lpattern(dash)) plotregion(lcolor(black) margin(b=0.25 t=0.25)) name(g2,replace) nodraw
	local graphs "`graphs' g2"
	graph combine `graphs', ycommon col(2) graphregion(color(white)) 
	graph export "$outputdir_fig\Figure_1.pdf", as(pdf) replace
	

